﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp2
{
    public class BaseDataErrorInfo : IDataErrorInfo
    {
        private string _error;
        public string this[string columnName]
        {
            get { return GetErrorFor(columnName); }
        }
        public string Error
        {
            get { return _error; }
            set { _error = value; }
        }
        public virtual string GetErrorFor(string columnName)
        {
            return string.Empty;
        }
    }
    public class Person : BaseDataErrorInfo
    {
        public string Name { get; set; }
        public override string GetErrorFor(string columnName)
        {
            if (columnName == "Name")
                if (string.IsNullOrEmpty(Name))
                    return "Name 不能为空";
            return base.GetErrorFor(columnName);
        }
    }
}
